package spider.example.t01.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequiredArgsConstructor
@Validated
@RequestMapping(value = "/test1")
public class Test1 {

    @GetMapping("/t1/{pid}")
    public Map<String,Object> t1(@PathVariable String pid){
        Map<String ,Object> map=new HashMap<>();
        map.put("key1",100);
        map.put("uri","/test1/t1");
        map.put("method","get");
        map.put("pid",pid);
        return  map;
    }
    @PostMapping("/t2")
    public Map<String,Object> t2(@RequestBody String str){
        Map<String ,Object> map=new HashMap<>();
        map.put("key1",100);
        map.put("uri","/test1/t2");
        map.put("method","post");
        log.info(str);
        return  map;
    }
    @PutMapping("/t3/{param}")
    public Map<String,Object> t3(@PathVariable String param){
        Map<String ,Object> map=new HashMap<>();
        map.put("key1",100);
        map.put("param",param);
        map.put("uri","/test1/t3");
        map.put("method","put");
        return  map;
    }
    @DeleteMapping("/t4")
    public Map<String,Object> t4(){
        Map<String ,Object> map=new HashMap<>();
        map.put("key1",100);
        map.put("uri","/test1/t4");
        map.put("method","delete");
        return  map;
    }

}
